package com.rui.patterns.state.after;

/**
 * @author : [锐神NO.3]
 * @version : [v1.0]
 * @className : Context
 * @createTime : [2022/2/24 15:01]
 * @description : [描述该类的功能]
 */

@SuppressWarnings("all")
public class Context {

    public static final OpeningState OPENING_STATE = new OpeningState();
    public static final ClosingState CLOSING_STATE = new ClosingState();
    public static final RunningState RUNNING_STATE = new RunningState();
    public static final StoppingState STOPPING_STATE = new StoppingState();

    /**
     * 定义一个当前状态变量
     */
    private LiftState liftState;

    public LiftState getLiftState() {
        return liftState;
    }

    /**
     * 设置当前状态对象
     * @param liftState 当前状态对象
     */
    public void setLiftState(LiftState liftState) {
        this.liftState = liftState;
        //设置当前状态对象中的contex对象
        this.liftState.setContext(this);
    }

    public void open() {
        this.liftState.open();
    }

    public void close() {
        this.liftState.close();
    }

    public void run(){
        this.liftState.run();
    }

    public void stop(){
        this.liftState.stop();
    }
}
